package com.zyz.I_多线程.线程池.SingleThreadExecutor;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author: vick
 * @Date: 2025/3/24
 * @Description:
 * @version: 1.0
 */
public class Test {
    public static void main(String[] args) {
        //创建一个只有一个线程的线程池
        ExecutorService executorService = Executors.newSingleThreadExecutor();


        for (int i = 0; i < 5; i++) {
            //执行指定的线程操作
            Demo demo = new Demo();
            executorService.execute(demo);
        }

        //关闭线程池
        executorService.shutdown();
    }
}
